package com.zilue.balance.returnresult;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * Created by ZD on 2017/5/25.
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class Result<T> {
    private boolean success;
    private String msg;
    private T data;
    public static Result createFailedResult(){
        return Result.builder().success(false).msg("失败").build();
    }
    public static Result createFailedResult(String msg){
        return Result.builder().success(false).msg(msg).build();
    }
    public static Result createSuccessResult(){
        return Result.builder().success(true).msg("成功").build();
    }
    public static <T> Result<T> createSuccessResult(T data){
        return (Result<T>) Result.builder().success(true).msg("成功").data(data).build();
    }
}
